package com.red.servlet.order;

import com.red.entity.User;
import com.red.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "OrderQueryServlet", value = "/queryOrder")

public class OrderQueryServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");

        User user = (User)req.getSession().getAttribute("user");

        List<Map<String, String>> orders = new OrderServiceImpl().queryOrder(user.getuID());

        req.setAttribute("orders", orders);

        req.getRequestDispatcher("/jsp/manage/myorders.jsp").forward(req, resp);
    }
}
